﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Media;
using System.Diagnostics;

namespace WebClientTest
{
    public partial class Form1 : Form
    {
        string url;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            WebClient wc = new WebClient();
            url = textBox1.Text.Trim();
            if (string.IsNullOrEmpty(url))
            {
                return;
            }
            Debug.WriteLine("URL: " + url);
            wc.OpenReadAsync(new Uri(url));
            wc.OpenReadCompleted += (s,arg) => {
                Image img = new Bitmap(arg.Result);
                
                this.BeginInvoke(new MethodInvoker(() =>
                {
                    this.pictureBox1.Image = img;
                })
                );
            };
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int lastIndexOfDot = url.LastIndexOf('.');
            
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }
    }
}
